🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / util / PlatformUtils.kt
Displaying Raw • Download
core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/util/PlatformUtils.kt cea2c3a015c2c3227f13a3ac9bc4e13c35bbd4ee (cea2c3a0) Text, 5.81 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tf0883e@fileTb4b4b4:Te6edf3SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooManyFunctionsTa5d6ff"Tb4b4b4)
Tff7b72package T7ee787org.meshtastic.core.ui.util
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787org.jetbrains.compose.resources.StringResource
Tff7b72import T7ee787org.meshtastic.core.common.util.CommonUri
T8b949e/** Returns a function to open the platform's NFC settings. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenNfcSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a function to show a toast message. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberShowToastTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3suspend Tb4b4b4(Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a function to show a toast message from a string resource. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberShowToastResourceTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3suspend Tb4b4b4(Te6edf3StringResourceTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a function to open the platform's map application at the given coordinates. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenMapTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Te6edf3latitudeTb4b4b4: Tffa657DoubleTb4b4b4, Te6edf3longitudeTb4b4b4: Tffa657DoubleTb4b4b4, Te6edf3labelTb4b4b4: Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a function to open the platform's browser with the given URL. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenUrlTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Te6edf3urlTb4b4b4: Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a launcher function to prompt the user to save a file. The callback receives the saved file URI. */
Tf0883e@Composable
Tff7b72expect Tff7b72fun Td2a8ffrememberSaveFileLauncherTb4b4b4(
Te6edf3onUriReceivedTb4b4b4: Tb4b4b4(Te6edf3CommonUriTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4,
Tb4b4b4)Tb4b4b4: Tb4b4b4(Te6edf3defaultFilenameTb4b4b4: Tffa657StringTb4b4b4, Te6edf3mimeTypeTb4b4b4: Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a launcher function to prompt the user to open/pick a file. The callback receives the selected file URI. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenFileLauncherTb4b4b4(Te6edf3onUriReceivedTb4b4b4: Tb4b4b4(Te6edf3CommonUri?Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4)Tb4b4b4: Tb4b4b4(Te6edf3mimeTypeTb4b4b4: Tffa657StringTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/**
* Returns a suspend function that reads up to [maxChars] characters of text from a [CommonUri]. Returns `null` if the
* file is empty or cannot be read.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberReadTextFromUriTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3suspend Tb4b4b4(Te6edf3uriTb4b4b4: Te6edf3CommonUriTb4b4b4, Te6edf3maxCharsTb4b4b4: Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657String?
T8b949e/** Keeps the screen awake while [enabled] is true. No-op on platforms that don't support it. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffKeepScreenOnTb4b4b4(Te6edf3enabledTb4b4b4: Tffa657BooleanTb4b4b4)
T8b949e/** Returns a launcher to open the platform's location settings. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenLocationSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a launcher to open the platform's Bluetooth settings. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenBluetoothSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/** Returns a launcher to open the platform's Wi-Fi settings. */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenWifiSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/**
* Returns whether GPS/location services are currently disabled at the system level. Always `false` on platforms where
* this concept doesn't apply.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffisGpsDisabledTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean
T8b949e/**
* Returns whether Bluetooth is currently turned off at the system level (the adapter exists but is disabled). Always
* `false` on devices without Bluetooth and on platforms where the concept doesn't apply.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffisBluetoothDisabledTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean
T8b949e/**
* Returns whether the device currently lacks any transport that can back the network-scan discovery (no active Wi-Fi,
* Ethernet, or VPN). Cellular alone is **not** sufficient — a carrier uplink does not place the device on the same
* segment as a Meshtastic node — so a cellular-only state surfaces the "connect to Wi-Fi" hint. The function name is
* historical: the original implementation checked Wi-Fi alone, later widened to Ethernet, and now also recognizes VPN
* (ZeroTier/Tailscale) as a valid reachability path for a TCP node. The name is retained to avoid churning the
* expect/actual contract and every consumer. Always `false` where the concept doesn't apply.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffisWifiUnavailableTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean
T8b949e/** Returns a function that opens this app's system settings page (where the user can change any permission). */
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberOpenAppSettingsTb4b4b4(Tb4b4b4)Tb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657Unit
T8b949e/**
* Returns the reactive [PermissionUiState] for the location permissions, recomputed on `ON_RESUME`. On platforms
* without runtime permissions the status is always [PermissionStatus.GRANTED].
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberLocationPermissionStateTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3PermissionUiState
T8b949e/**
* Returns the reactive [PermissionUiState] for the Bluetooth scan/connect permissions. On pre-Android-12 devices BLE
* scanning is gated by the location permission, so the returned state delegates to [rememberLocationPermissionState].
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberBluetoothPermissionStateTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3PermissionUiState
T8b949e/**
* Returns the reactive [PermissionUiState] for the POST_NOTIFICATIONS permission. Always [PermissionStatus.GRANTED] on
* API levels / platforms that don't gate notifications behind a runtime permission.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberNotificationPermissionStateTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3PermissionUiState
T8b949e/**
* Returns the reactive [PermissionUiState] for the ACCESS_LOCAL_NETWORK permission. Always [PermissionStatus.GRANTED]
* on API levels / platforms that don't gate local-network access behind a runtime permission.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberLocalNetworkPermissionStateTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3PermissionUiState
T8b949e/**
* Returns the reactive [PermissionUiState] for the CAMERA permission. Always [PermissionStatus.GRANTED] on platforms
* that don't require a runtime camera permission.
*/
Tf0883e@Composable Tff7b72expect Tff7b72fun Td2a8ffrememberCameraPermissionStateTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3PermissionUiState
Served by rngit 1.5.0 - Generated in 0.05s